package test_package;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13.11.13
 * Time: 13:20
 * To change this template use File | Settings | File Templates.
 */

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.util.concurrent.TimeUnit;


public class vmdaily_comments {
    @Test
    public static void vmdaily_comments_nologin () {
        WebDriver driver = new FirefoxDriver();
        driver.get("http://vmdaily.ru/news/2013/11/10/gruppa-abba-mozhet-vossoedinitsya-221980.html");
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        Assert.assertTrue(driver.findElement(By.xpath("//*[@id=\"user-info\"]/form/div[1]/div[2]/div[3]/div[1]/a")).getText().contains("Регистрация"));
        driver.findElement(By.xpath("/html/body/div/section/section/article/div[9]/div[1]/button")).click();
        driver.findElement(By.className("editor")).sendKeys("This is new test comment");
        driver.findElement(By.xpath("/html/body/div/section/section/article/div[9]/div[2]/form/div[4]/input[4]")).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

        driver.get("http://vmdaily.ru/news/2013/11/10/gruppa-abba-mozhet-vossoedinitsya-221980.html");
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        Assert.assertTrue(driver.findElement(By.xpath("/html/body/div/section/section/article/div[1]/h3")).getText().contains("Группа ABBA может"));
        Assert.assertTrue(driver.findElement(By.tagName("body")).getText().contains("This is new test comment"));

        driver.quit();

    }
}
